# Base层提供抽象的方法行为
# 其实是selenium的2次封装
from selenium.webdriver.support.select import Select


class Base():
    def __init__(self, driver):
        self.driver = driver

    def open(self, url):
        self.driver.get(url)
        self.driver.maximize_window()

    def find_element(self, *locator):
        return self.driver.find_element(*locator)

    def input(self, locator, text):
        self.find_element(*locator).send_keys(text)

    def click(self, locator):
        self.find_element(*locator).click()

    def into_frame(self, frame_name):
        self.driver.switch_to.frame(frame_name)

    def out_frame(self):
        self.driver.switch_to.default_content()

    def select_by_text(self, locator, text):
        Select(self.find_element(*locator)).select_by_visible_text(text)
